package com.zlkj.pro.modular.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlkj.pro.modular.business.entity.ProtocolEntity;
import com.zlkj.pro.modular.business.mapper.ProtocolMapper;
import com.zlkj.pro.modular.business.model.dto.ProtocolDTO;
import com.zlkj.pro.modular.business.service.ProtocolService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;


/**
 * @author liyang
 * @date 2024/4/6
 * @time 14:34
 */
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class ProtocolServiceImpl extends ServiceImpl<ProtocolMapper, ProtocolEntity> implements ProtocolService {

    @Override
    public String findDetail() {
        return super.getById(1L).getContent();
    }


    @Override
    public boolean edit(String content) {
        ProtocolEntity entity = new ProtocolEntity();
        entity.setId(1L);
        entity.setContent(content);
        return super.updateById(entity);
    }

    @Override
    public Map<String, Object> findFlowDetail() {
        Map<String, Object> map = new HashMap<>();
        map.put("content", super.getById(2L).getContent());
        map.put("content2", super.getById(3L).getContent());
        return map;
    }

    @Override
    public boolean editFlow(ProtocolDTO dto) {
        ProtocolEntity entity = new ProtocolEntity();
        entity.setId(2L);
        entity.setContent(dto.getContent());
        super.updateById(entity);

        ProtocolEntity entity2 = new ProtocolEntity();
        entity2.setId(3L);
        entity2.setContent(dto.getContent2());
        super.updateById(entity2);
        return true;
    }

}
